package com.crack.spansframe;

import android.graphics.Color;
import android.text.TextPaint;
import android.text.style.UnderlineSpan;
import android.widget.TextView;
import android.widget.Toast;

import com.crack.spansframe.extra.Clickable;

/**
 * Created by archermind on 16-4-19.
 */
public class UrlClickSpan extends UnderlineSpan implements Clickable {
    String url;

    public UrlClickSpan(String url) {
        this.url = url;
    }

    @Override
    public void updateDrawState(TextPaint ds) {
        ds.setColor(Color.rgb(148, 135, 96));
        ds.setUnderlineText(true);
    }

    @Override
    public void onClick(TextView textView) {
        Toast.makeText(textView.getContext(), url, Toast.LENGTH_SHORT).show();
    }
}
